package com.et.core.store

import android.database.Cursor
import androidx.room.*
import io.reactivex.Completable
import io.reactivex.Flowable
import io.reactivex.Single

interface BaseDao

@Dao
interface IFileDao : BaseDao {

    @Query("SELECT * FROM table_file")
    fun all(): Flowable<MutableList<FileEntity>>

    @Query("SELECT * FROM table_file")
    fun findAll(): Cursor

    @Insert(onConflict = OnConflictStrategy.REPLACE, entity = FileEntity::class)
    fun insert(fileEntity: FileEntity): Completable

    @Query("DELETE FROM table_file WHERE id in (:ids)")
    fun deleteById(ids: Int): Int

    @Query("DELETE FROM table_file WHERE file_status in (:status)")
    fun deleteByStatus(status: Int = FileEntity.STATUS_DELETE): Int

    @Query("DELETE FROM table_file")
    fun deleteAll(): Completable

    @Query("DELETE FROM table_file WHERE id in (:ids)")
    fun delete(ids: String): Int

    @Update(entity = FileEntity::class)
    fun updateByProvider(channel: FileEntity): Int

    @Delete(entity = FileEntity::class)
    fun delete(channel: FileEntity): Single<Int>

    @Update(entity = FileEntity::class)
    fun update(channel: FileEntity): Completable
}